<template>
  <div class="hotsearch">
    <div class="history" v-if="historylist.length != 0">
      <div class="top">
        <h3>搜索历史</h3>
        <span @click="$emit('toclear')"></span>
      </div>
      <ul>
        <li
          v-for="(item, index) in historylist"
          :key="index"
          @click="$emit('gotosearch', item)"
        >
          {{ item }}
        </li>
      </ul>
    </div>
    <div class="hotsearch">
      <h3>热门搜索</h3>
      <ul>
        <li
          v-for="(item, index) in hotsearchlist"
          :key="index"
          :style="{
            color: item.color,
            backgroundColor: item.background_color,
            borderColor: item.borderColor,
          }"
          @click="$emit('gotosearch', item.title)"
        >
          {{ item.title }}
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
export default {
  props: ["hotsearchlist", "historylist"],
};
</script>

<style lang="less" scoped>
.hotsearch {
  .hotsearch,
  .history {
    margin-top: 15px;
    h3 {
      font-size: 13px;
      font-weight: bold;
    }
    ul {
      display: flex;
      flex-wrap: wrap;
      margin-top: 5px;
      li {
        padding: 5px 10px;
        border-radius: 3px;
        // border-color: #000;
        color: #3f3f3f;
        background-color: #fafafa;
        border: 1px solid transparent;
        // margin-right: 5px;
        font-size: 12px;
        margin-top: 5px;
        transform-origin: left;
        transform: scale(0.9);
      }
    }
  }
  .history {
    .top {
      display: flex;
      justify-content: space-between;
      align-items: center;
      span {
        width: 15px;
        height: 15px;
        background-image: url("../assets/sde.png");
        background-size: 100%;
        background-position: center;
      }
      h3 {
        margin: 0;
      }
    }
  }
}
</style>